package com.mxgraph.swing.test;

import java.util.ArrayList;

import javax.swing.ImageIcon;

import com.mxgraph.model.mxCell;
import com.mxgraph.model.mxGeometry;
import com.mxgraph.swing.examples.editor.EditorPalette;
import com.mxgraph.util.mxPoint;

public class MyEditorPalette extends EditorPalette {
	public void addEdgeTemplate(final String name, ImageIcon icon,
			String style, int width, int height, Object value)
	{
		mxGeometry geometry = new mxGeometry(0, 0, width, height);
		geometry.setTerminalPoint(new mxPoint(0, height), true);
		geometry.setTerminalPoint(new mxPoint(width, 0), false);
		geometry.setRelative(true);

		mxCell cell;
		
		cell = new MyCell(value, geometry, style);

		cell.setEdge(true);

		addTemplate(name, icon, cell);
	}
	
	public void addTemplate(final String name, ImageIcon icon, String style,
			int width, int height, Object value)
	{
		MyCell cell = new MyCell(value, new mxGeometry(0, 0, width, height),
				style);
		cell.setVertex(true);
		cell.setCellList(null);
		ArrayList a = new ArrayList();
		for (int i = 0; i < 3; i++) {
			MyCell cc=new MyCell();
			cc.setMyString(Integer.toString(i));
			a.add(cc);
		}
		cell.setCellList(a);
		

		addTemplate(name, icon, cell);
	}
}
